package fiuba.algo3.gpschallenge.gui;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.EventQueue;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import fiuba.algo3.gpschallenge.Controlador.Controlador;
import fiuba.algo3.gpschallenge.modelo.Juego;




public class VentanaPrincipal extends JFrame implements Agregable {

	private static final long serialVersionUID = 1L;
	private Container contentPane;
	private Controlador control;
	private Juego modelo;
	private final int ALTO = 500;
	private final int ANCHO = 700;

	public VentanaPrincipal (Juego modelo, Controlador control){

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(700, 449);
		contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());
		
		setContentPane(contentPane);
		this.modelo = modelo;
		this.control = control;
		PanelInicial panelInicial = new PanelInicial(this, modelo, control);
		getContentPane().add(panelInicial, BorderLayout.CENTER);

	}

	@Override
	public void agregarComponente(JComponent componenteAgregar, Object constraints){	//permite que los paneles cambie la vista del Frame.
			
		//para BorderLayOut --> constraints: BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, and BorderLayout.CENTER.
			contentPane.add(componenteAgregar, constraints);
			revalidate();
			repaint();
			componenteAgregar.requestFocus();
		}

	
	@Override
	public void limpiarVentana (){
		contentPane.removeAll();
		invalidate();
		repaint();
	}
	
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Juego modelo = new Juego();
					Controlador control = new Controlador(modelo);
					VentanaPrincipal frame = new VentanaPrincipal(modelo, control);
					frame.setVisible(true);
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
}
